//
//  GQProfileNearCell.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/29.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQProfileNearCell.h"
#define kFamousMargin 20

@implementation GQProfileNearCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpChildView];
    }
    return self;
}

- (void)setUpChildView
{
    CGFloat iconWidth = 40;
    CGFloat vertifyWidth = 15;
    CGFloat concernMargin = 15;
    CGFloat concernWidth = 57;
    CGFloat concernHeight = 25;
    
    //创建头像
    
    UIButton *iconImage = [[UIButton alloc] initWithFrame:CGRectMake(kFamousMargin, 10, iconWidth, iconWidth)];
    [iconImage setImage:[UIImage imageWithRoundName:@"icon"] forState:UIControlStateNormal];
    //创建认证用户
    UIImageView *vertify = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"relationship_famous_accreditation"]];
    vertify.x = iconImage.width - vertifyWidth;
    vertify.y = iconImage.height - vertifyWidth;
    vertify.width = vertifyWidth;
    vertify.height = vertifyWidth;
    
    [iconImage addSubview:vertify];
    [self addSubview:iconImage];
    
    //创建姓名标签
    NSString *text = @"百里放羊放羊放羊";
    
    CGSize nameSize = [text boundingRectWithSize:CGSizeMake(MAXFLOAT, 18) options:NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
    
    
    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(iconImage.frame) + 20, CGRectGetMinX(iconImage.frame) - 5, nameSize.width, nameSize.height)];
    nameLabel.text = text;
    nameLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:nameLabel];
    
    //创建距离标签
    
    UILabel *distanceLabel = [[UILabel alloc] init];
    distanceLabel.x = CGRectGetMaxX(nameLabel.frame) + 10;
    distanceLabel.width = 100;
    distanceLabel.height = 18;
    distanceLabel.font = [UIFont systemFontOfSize:12];
    distanceLabel.y = nameLabel.y;
    distanceLabel.text = @"100米";
    distanceLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:distanceLabel];
    
    
    
    //创建头衔标签
    UILabel *honourLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameLabel.x, CGRectGetMaxY(nameLabel.frame), 200, 18)];
    honourLabel.font = [UIFont systemFontOfSize:12];
    honourLabel.text = @"中国书画协会名誉会长";
    honourLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:honourLabel];
    
    UIButton *concernBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width - concernMargin - concernWidth, (60 - concernHeight) / 2, concernWidth, concernHeight)];
    [concernBtn setImage:[UIImage imageNamed:@"relationship_concern"] forState:UIControlStateNormal];
    [concernBtn setImage:[UIImage imageNamed:@"relationship_concerned"] forState:UIControlStateSelected];
    [concernBtn addTarget:self action:@selector(concernBtnDidClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:concernBtn];
    
}

- (void)concernBtnDidClick:(UIButton *)btn
{
    
    btn.selected = !btn.selected;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
}

@end
